package com.cy.pj.goods.service.impl;

import com.cy.pj.goods.dao.GoodsDao;
import com.cy.pj.goods.pojo.Goods;
import com.cy.pj.goods.service.GoodsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class GoodsServiceImpl implements GoodsService {
    private static final Logger log=
            LoggerFactory.getLogger(GoodsServiceImpl.class);

    @Autowired
    private GoodsDao goodsDao;

    @Override
    public List<Goods> findGoods() {
        long t1=System.currentTimeMillis();
        log.info("star {}",t1);
        List<Goods> list=goodsDao.findGoods();
        long t2=System.currentTimeMillis();
        log.info("end {}",t2);
        log.info("执行时长-->{}",t2-t1);
        return list;
    }

    @Override
    public int deleteById(Integer id) {
        if (id==null||id<1)
            throw new IllegalArgumentException("传入的id值不合法");
        long t1=System.currentTimeMillis();
        int rows=goodsDao.deleteById(id);
        long t2=System.currentTimeMillis();
        log.info("delete-->{}",t2-t1);
        return rows;
    }

    @Override
    public int deleteObject(Integer... ids) {
        long t1=System.currentTimeMillis();
        int rows=goodsDao.deleteObject(ids);
        long t2=System.currentTimeMillis();
        log.info("delete-->{}",t2-t1);
        return rows;
    }
}
